using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using System.Collections;
using System.Data.SqlClient;
/// <summary>
///
/// </summary>
public class BindDropDownList
{
   public BindDropDownList()
   {
   }
   public static void SetDropDownList(ArrayList ArrayL, DropDownList DDL,string FirstStr)
   {
      ArrayL.Insert(0, FirstStr);
      DDL.Items.Clear();
      for (int i = 0; i < ArrayL.Count; i++)
      {
         DDL.Items.Add(ArrayL[i].ToString());
      }
      DDL.SelectedIndex = 0;
   }
   /// <summary>
   /// DropDownList 
   /// </summary>
   /// <param name="DDL"></param>
   /// <param name="Sqlstring"></param>
   /// <param name="SqlKey"></param>
   /// <param name="FirstStr"></param>
   public static void SetDropDownList(DropDownList DDL, string Sqlstring, string SqlKey, string FirstStr)
   {
      SqlConnection con = new SqlConnection(publicConn.LinkDataBase());
      con.Open();
      try
      {
         SqlDataAdapter ada = new SqlDataAdapter(Sqlstring, con);
         DataSet ds = new DataSet();
         ada.Fill(ds);
         DDL.DataSource = ds;
         DDL.DataTextField = SqlKey;
         DDL.DataValueField = SqlKey;
         DDL.DataBind();
         DDL.Items.Insert(0, FirstStr);
      }
      catch
      {
      }
      finally
      {
         con.Close();
      }
   }
}
